#!/bin/sh

added_key="[dgggit09-rd.huawei.com]:29418,[10.1.21.40]:29418 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxhN+TnUC8a91hpMJmuYMOl+X7S2XlyGhhIQEBvZTcjqF/FXN2u9Jn4SkeXsAi6J+P1q3nFKbgqQKpug2f41Q6xufXn4wsnACcjVAzVmSSe+qvMUh84oiI7j7c7MZ9iQhxgMzrJIMoP20wsVjEyQtT2jlrxb8+h6dzq+sk2HhX4wA+rsIOFrSQvKdIjrphCoVJ+vadX+dtk5BD+Etdu22XlPl3AfZONpssPmEc/hM96u44NtHE+BujDhBhXYW8VKYKW1ZiQ0x/27YR2jss572jlEegOCMq/GmoiRwWM7Y7ZBZ8rrEg85lpjIDKCfh8r1Hiz6wrrWfQGdSHukUEL2aqQ=="

if cat /root/.ssh/known_hosts | grep "dgggit09-rd.huawei.com" > /dev/null;then
    echo "Key is OK"
else
    echo "$added_key" >> /root/.ssh/known_hosts
fi

ssh -p 29418 peulerosci@dgggit09-rd.huawei.com gerrit query --files --current-patch-set change:$GERRIT_CHANGE_NUMBER | grep file: | awk '{print $2}' > files_list
if [ $? -ne 0 ];then
    echo "Get gerrit info failed"
    exit $?
fi
python check_binary_files_tmp.py
